<template>
  <div style="background-color: #dedede">
    <p>子组件A</p>
    <pre>{{ types }}</pre>
  </div>
</template>
<script>
import $ from "jquery";
export default {
  name: "ChildPageA",
  data() {
    return {
      types: {},
    };
  },
  methods: {
    loadTypes() {
      $.get("http://139.196.82.122:8080/api/v1/index/category", (data) => {
        this.types = data;
      });
    },
  },
  activated() {
    this.loadTypes();
    // 组件从缓存状态切换到显示状态
    console.log("ChildPageA-activated-从缓存状态切换到显示");
  },
  deactivated() {
    // 组件从显示状态切换到缓存状态
    console.log("ChildPageA-deactivated-从显示状态切换到缓存");
  },
  beforeCreate() {
    console.log("ChildPageA-beforeCreate");
  },
  created() {
    // this.loadTypes();
    console.log("ChildPageA-created-完成类型ajax得请求操作");
  },
  destroyed() {
    console.log("ChildPageA-destroyed");
  },
};
</script>
